<?php
namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
use App\Model\OperationLogs;
use App\Model\RoomFrame;

class RoomFrameController extends BaseController
{
    protected $model = null;

    public function __construct(Request $request)
    {
        parent::__construct($request);
        $this->model = new RoomFrame();
    }

    //房间边框新增
    public function roomFrameAdd(Request $request){
        $res = $this->model->roomFrameAdd($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '房间边框新增');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //房间边框编辑
    public function roomFrameEdit(Request $request){
        $res = $this->model->roomFrameEdit($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '房间边框编辑');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //房间边框下发记录新增
    public function roomFrameUserAdd(Request $request){
        $res = $this->model->roomFrameUserAdd($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '房间边框下发记录新增');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //房间边框下发记录编辑
    public function roomFrameUserEdit(Request $request){
        $res = $this->model->roomFrameUserEdit($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '房间边框下发记录编辑');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //房间边框下发记录删除
    public function roomFrameUserDel(Request $request){
        $res = $this->model->roomFrameUserDel($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '房间边框下发记录删除');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //房间边框列表
    public function roomFrameList(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->roomFrameList($request));
    }

    //房间边框下发记录列表
    public function roomFrameLogList(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->roomFrameLogList($request));
    }

}
